package com.jacquesh;

import org.apache.flink.streaming.api.datastream.ConnectedStreams;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.co.RichCoMapFunction;

public class FlinkDemo0007 {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment environment =
                StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<String> stream1 = environment
                .socketTextStream("192.168.88.180", 8888);
        DataStreamSource<String> stream2 = environment
                .socketTextStream("192.168.88.181", 8888);
        ConnectedStreams connectedStreams = stream1.connect(stream2);
        connectedStreams.getFirstInput().print();
        connectedStreams.getSecondInput().print();
        DataStream dataStream = connectedStreams.map(new RichCoMapFunction<String, String, String>() {
            @Override
            public String map1(String s) throws Exception {
                return s;
            }

            @Override
            public String map2(String s) throws Exception {
                return s;
            }
        });
        environment.execute("connect demo");
    }
}
